package main

import (
	"encoding/json"
	"fmt"
	"github.com/gookit/goutil/strutil"
	"time"
)

type Cat struct {
	Name  string `json:"name"`
	Age   int    `json:"age"`
	Color string `json:"color"`
}

func main() {

	//创建cat对象
	var cat1 Cat
	cat1.Age = 2
	cat1.Color = "白"
	cat1.Name = "小白白"
	fmt.Println(cat1)

	cat2 := Cat{
		Name:  "小黑",
		Age:   2,
		Color: "黑",
	}
	fmt.Println(cat2)
	time.Now()
	chars := strutil.RandomChars(2)
	fmt.Println(chars)
	title := strutil.Title("23")
	fmt.Println(title)

	marshal, _ := json.Marshal(cat2)
	fmt.Println(string(marshal))

	var cat3 Cat
	err := json.Unmarshal(marshal, cat3)
	if err == nil {

	}
	fmt.Println(cat3)

}
